<%@ page import="com.bdqn.t382.lx.pojo.SysUser" %><%--
  Created by IntelliJ IDEA.
  User: Lenovo
  Date: 2025/2/27
  Time: 14:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
    <style>
        table tr:nth-child(odd) {
            background-color: cornsilk;
        }

        a {
            color: red;
        }
    </style>
</head>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<body>
<%--<%--%>
<%--    SysUser user = (SysUser) session.getAttribute("user");--%>
<%--    if (user == null) {--%>
<%--        response.sendRedirect("erro.jsp");--%>
<%--    }--%>
<%--%>--%>
<div align="center"><h3>${user.realName}欢迎您!</h3></div>
<div align="center">
    <h1>图书信息</h1>
    <table align="center" border="1">
        <tr>
            <td>图书名称</td>
            <td>图书作者</td>
            <td>购买时间</td>
            <td>图书分类</td>
            <td>操作</td>
        </tr>
        <c:forEach items="${list}" var="book">
            <tr>
                <td>${book.b_name}</td>
                <td>${book.b_author}</td>
                <td>${book.b_time}</td>
                <td>
                    <c:if test="${book.b_type==1}">计算机/软件</c:if>
                    <c:if test="${book.b_type==2}">小说/文摘</c:if>
                    <c:if test="${book.b_type==3}">杂项</c:if>
                </td>
                <td>
                    <a class="view" href="view?b_id=${book.b_id}">查看</a>
                    <a class="sc" href="delete?b_id=${book.b_id}">删除</a>
                </td>
            </tr>
        </c:forEach>
    </table>
    <div align="center"><a href="add">新增图书信息</a></div>
</div>
</body>
</html>
<script>
    $(document).ready(function () {
        $('.sc').click(function (event) {
            var confirmDelete = confirm('确定要删除该条数据吗？');
            if (!confirmDelete) {
                event.preventDefault();
            }
        });
    });
</script>